package com.jeff.tianti.cms.service;

import com.jeff.tianti.cms.entity.MemberOf;
import com.jeff.tianti.cms.dao.MemberOfDao;
import com.jeff.tianti.cms.dto.MemberOfQueryDTO;
import com.jeff.tianti.common.service.CommonService;
import com.jeff.tianti.common.entity.PageModel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author liuyi
 * @desc MemberOfService类
 * @date 2019-06-19
 */
@Service
public class MemberOfService extends CommonService<MemberOf, String> {

    @Autowired
    private MemberOfDao memberOfDao;

    @Autowired
    public void setMemberOfDao(MemberOfDao memberOfDao) {
        super.setCommonDao(memberOfDao);
    }

    public PageModel<MemberOf> queryMemberOfPage(MemberOfQueryDTO memberOfQueryDTO) {
        return this.memberOfDao.queryMemberOfPage(memberOfQueryDTO);
    }

    public List<MemberOf> queryMemberOfList(MemberOfQueryDTO memberOfQueryDTO) {
        return this.memberOfDao.queryMemberOfList(memberOfQueryDTO);
    }

    public List<MemberOf> findAllByIds(List<String> ids) {
        if (ids == null || ids.size() <= 0) {
            return new ArrayList<>();
        }
        return memberOfDao.findAll(ids);
    }

    public void saveMemberOf(MemberOf memberOf) {
        if (StringUtils.isNotBlank(memberOf.getId())) {
            update(memberOf);
        } else {
            save(memberOf);
        }
    }
}